import request from '@/plugins/axios'
const config = require('config')

// 获取table数据
export function getData(data) {
  return request({
    url: `${config.effengine.path}/v1/sys/parameter/query`,
    method: 'post',
    data
  })
}

// 新增或修改数据源
export function addOrUpdateData(data, type) {
  let url =
    type === 'add' ? '/v1/sys/parameter/add' : '/v1/sys/parameter/update'
  return request({
    url: `${config.effengine.path}${url}`,
    method: 'post',
    headers: {
      'Content-Type': 'application/x-www-form-urlencoded'
    },
    data
  })
}

// 获取详情
export function check(data) {
  return request({
    url: `${config.effengine.path}/v1/sys/parameter/findById?codeId=${data}`,
    method: 'get'
  })
}

// 删除数据
export function deleteData(data) {
  return request({
    url: `${config.effengine.path}/v1/sys/parameter/delete`,
    method: 'post',
    headers: {
      'Content-Type': 'application/x-www-form-urlencoded'
    },
    data
  })
}

// 同步
export function syncData() {
  return this.request({
    url: `${config.effengine.path}/v1/sys/parameter/sync`,
    method: 'GET'
  })
}
